﻿using System;
using NHibernate.Mapping.ByCode;
using SellAndBuy.Domain.Entities;

namespace SellAndBuy.Infrastructure.Data.Mappings
{
    public class PictureInfoMap
    {
        private const int MaxImageLength = 3145728; // = 3 MB

        public static Action<IComponentElementMapper<PictureInfo>> Mapping()
        {
            return c =>
            {
                c.Property(p => p.Title, map => map.Length(150));
                c.Property(p => p.FileName, map => map.NotNullable(true));
                c.Property(p => p.IsMain, map => map.NotNullable(true));
                c.Property(p => p.Picture, map => { map.NotNullable(true); map.Length(MaxImageLength); });
            };
        }
    }
}